/*
 * @Description: 顶栏导航组件
 * @Author: Yong
 * @Date: 2021-09-25 15:15:18
 * @LastEditTime: 2021-09-26 22:18:39
 */
import React from 'react'
import { withRouter } from 'react-router'
import { NavBar } from 'antd-mobile'
import propTypes from 'prop-types'
// 导入样式
import styles from './index.module.css'

function HavHeader ({ children, history, onLeftClick, className, rightContent }) {
    const defaultOnLeftClick = () => { history.go(-1) }
    return (
        <NavBar
            className={ [ styles.navBar, className || '' ].join('  ') }
            mode="light"
            icon={<i className="iconfont icon-back" />}
            onLeftClick={onLeftClick || defaultOnLeftClick}
            rightContent={rightContent}
        >
            { children}
        </NavBar>
    )
}

HavHeader.propTypes = {
    children: propTypes.string.isRequired,
    onLeftClick: propTypes.func,
    className: propTypes.string,
    rightContent: propTypes.array
}

export default withRouter(HavHeader)
